package com.alibaba.cloud.ai.example.flight.config;

import com.alibaba.cloud.ai.example.flight.model.Flight;
import com.alibaba.cloud.ai.example.flight.model.FlightData;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class FlightDataConfig {
    @Bean("flightData")
    public FlightData initFlightData() {
        System.out.println("-----initFlightData初始化航班数据，只会创建一次");
        FlightData flightData = new FlightData();
        flightData.setFlightList(initFlights());
        return flightData;
    }

    private List<Flight> initFlights() {
        List<Flight> flights = new ArrayList<>();
        flights.add(new Flight(101, "徐庶", "2024-11-14", "青岛", "上海", "已确认", "ECONOMY"));
        flights.add(new Flight(102, "诸葛", "2024-11-16", "青岛", "天津", "已确认", "PREMIUM_ECONOMY"));
        flights.add(new Flight(103, "百里", "2024-11-18", "成都", "北京", "已确认", "ECONOMY"));
        flights.add(new Flight(104, "楼兰", "2024-11-20", "深圳", "杭州", "已确认", "BUSINESS"));
        flights.add(new Flight(105, "庄周", "2024-11-22", "成都", "大连", "已确认", "ECONOMY"));
        return flights;
    }
}
